package cn.study.feignclient.controller;

import cn.study.feignclient.entity.Animal;
import cn.study.feignclient.entity.User;
import cn.study.feignclient.service.UserSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.jws.soap.SOAPBinding;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserSerivce userSerivce;

    @PostMapping("/test1")
    public Map<String,Object> test1(@RequestBody User user, @RequestBody Animal animal){
        Map<String,Object> dto = new HashMap<>();
        dto.put("id", user.getId());
        dto.put("aid", animal.getAid());
        return this.userSerivce.test1(dto);
    }
    @PostMapping("/test")
    public Map<String,Object> test(@RequestBody Map<String,Object> user,@RequestParam String key){
        return this.userSerivce.test(user, key);
    }
    @GetMapping("/findById")
    public User findById(Integer id) {
        return this.userSerivce.findById(id);
    }
    /*@GetMapping("/findByIdAndName")
    public User findByIdAndName(Integer id,String name){
        return this.userSerivce.findByIdAndName(id, name);
    }*/
    @GetMapping("/findByIdAndName")
    public User findByIdAndName(@RequestParam Map<String,Object> searchMap){
        return this.userSerivce.findByIdAndName(searchMap);
    }
    @GetMapping("/findByCondition")
    public User findByCondition(Map<String, Object> condition) {
        return this.userSerivce.findByCondition(condition);
    }
    @GetMapping("/findByEntity")
    public User findByEntity(User user) {
        return this.userSerivce.findByEntity(user);
    }
    @PostMapping("/addUser")
    public User addUser(User user) {
        return this.userSerivce.addUser(user);
    }
    @PostMapping("/addUserMap")
    public Map<String, Object> addUser(@RequestBody Map<String, Object> user) {
        System.out.println(1);
        return this.userSerivce.addUserMap(user);
    }



}
